#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //创建菜单栏并设置
    QMenuBar* menuBar = new QMenuBar();
    this->setMenuBar(menuBar);

    //创建菜单并设置
    QMenu* menu = new QMenu("菜单");
    menuBar->addMenu(menu);

    //创建菜单项并设置
    QAction* action1 = new QAction("菜单项1");
    QAction* action2 = new QAction("菜单项2");
    menu->addAction(action1);
    //在菜单项1和菜单项2之间创建分割线
    menu->addSeparator();
    menu->addAction(action2);


}

MainWindow::~MainWindow()
{
    delete ui;
}

